package cn.tedu.sgs.garbage.controller;

import cn.tedu.sgs.base.response.JsonResult;
import cn.tedu.sgs.garbage.pojo.dto.GarbageQuery;
import cn.tedu.sgs.garbage.pojo.dto.GarbageSaveParam;
import cn.tedu.sgs.garbage.pojo.vo.GarbageVO;
import cn.tedu.sgs.garbage.service.GarbageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/garbage")
public class GarbageController {
	@Autowired
	GarbageService garbageService;

	@GetMapping("select")
	public JsonResult selectGarbage(GarbageQuery garbageQuery){
		log.debug("查询垃圾参数:{}",garbageQuery);
		List<GarbageVO> list = garbageService.selectGarbage(garbageQuery);
		return JsonResult.ok(list);
	}

	@PostMapping("save")
	public JsonResult saveGarbage(GarbageSaveParam garbageSaveParam){
		log.debug("保存垃圾参数:{}",garbageSaveParam);
		garbageService.saveGarbage(garbageSaveParam);
		return JsonResult.ok();
	}

	@PostMapping("delete/{id}")
	public JsonResult deleteGarbage(@PathVariable Long id){
		log.debug("删除垃圾参数:{}",id);
		garbageService.deleteGarbage(id);
		return JsonResult.ok();
	}
}
